package training.hari.reflections;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectionsDemo {
	
	public void scanObject(Object object){
		System.out.println(object.getClass());
		Class classObject = object.getClass();
		System.out.println(classObject.getCanonicalName());
		
		Method[] methods = classObject.getMethods();
		for (Method method : methods) {
			System.out.println(method.getName() );
		}
		
		Constructor[] constructors = classObject.getConstructors();
		try {
			constructors[0].newInstance();
		} catch (InstantiationException | IllegalAccessException
				| IllegalArgumentException | InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	public static void main(String[] args) {
		
		ReflectionsDemo demo = new ReflectionsDemo();
		demo.scanObject(demo);
	}

}
